
package net.minecraft.src;

import java.util.Random;

public class ItemShellPowder extends Item
{

    public ItemShellPowder(int i)
    {
        super(i);
    }

    public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
    {
        if(!entityplayer.func_35190_e(i, j, k))
        {
            return false;
        }
            int i1 = world.getBlockId(i, j, k);
            if(i1 == mod_pph.prehistoricSapling.blockID)
            {
                if(!world.multiplayerWorld)
                {
                    ((BlockPrehistoricSapling)mod_pph.prehistoricSapling).growTree(world, i, j, k, world.rand);
                    itemstack.stackSize--;
                }
                return true;
            }
            if(i1 == mod_pph.prehistoricGrass.blockID)
            {
                if(!world.multiplayerWorld)
                {
                    itemstack.stackSize--;
label0:
                    for(int j1 = 0; j1 < 128; j1++)
                    {
                        int k1 = i;
                        int l1 = j + 1;
                        int i2 = k;
                        for(int j2 = 0; j2 < j1 / 16; j2++)
                        {
                            k1 += itemRand.nextInt(3) - 1;
                            l1 += ((itemRand.nextInt(3) - 1) * itemRand.nextInt(3)) / 2;
                            i2 += itemRand.nextInt(3) - 1;
                            if(world.getBlockId(k1, l1 - 1, i2) != mod_pph.prehistoricGrass.blockID || world.isBlockNormalCube(k1, l1, i2))
                            {
                                continue label0;
                            }
                        }

                        if(world.getBlockId(k1, l1, i2) != 0)
                        {
                            continue;
                        }
                        if(itemRand.nextInt(10) <= 3)
                        {
                            world.setBlockAndMetadataWithNotify(k1, l1, i2, mod_pph.prehistoricPlant.blockID, 2);
                            continue;
                        } else
						{
                            world.setBlockAndMetadataWithNotify(k1, l1, i2, mod_pph.prehistoricPlant.blockID, 1);
                            continue;
                        }
                    }

                }
                return true;
            }
        return false;
    }

}
